<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<canvas id="canvas" style="border: 1px solid red;"></canvas>
		<script type="text/javascript">
			var canvas = document.getElementById("canvas")
			var cxt = canvas.getContext("2d")
			var img = new Image();
			canvas.width = 400;
			canvas.height = 300;
			img.src = "img/flower.png"
			img.onload = function() {
				var pattern = cxt.createPattern(img, "repeat")
				cxt.fillStyle = pattern;
				cxt.fillRect(0, 0, canvas.width, canvas.height)
			}			
		</script>
	</body>
</html>
